{extend name="layout:base" /}
{block name="page_content"}
  <div class="row maintop">
    <div class="col-xs-12">
      <form name="form_search" class="form-search form-inline" method="get" action="{:url('index')}">
        <?php if($auth->check('create')): ?>
          <div class="form-group">
            <a href="{:url('create')}" class="btn btn-sm btn-primary mr-10">
              <i class="ace-icon fa fa-plus bigger-110"></i>
              添加
            </a>
          </div>
        <?php endif; ?>
        <div class="form-group">
          <label>分类：</label>
          <select name="second_category_id" class="form-control">
            <option value="">请选择分类</option>
            {volist name="categories" id="cat"}
              <?php if($cat['id'] == $second_category_id): ?>
                <option value="{$cat.id}" selected="selected">{$cat.title}</option>
              <?php else: ?>
                <option value="{$cat.id}">{$cat.title}</option>
              <?php endif; ?>
            {/volist}
          </select>
        </div>
        <div class="form-group">
          <label>发布时间：</label>
          <input type="text" name="egt_time" id="egt_time" placeholder="开始日期" class="datepicker" value="{$param.egt_time|default='0'|format_show_time=###,'only_date'}">
          <label> -- </label>
          <input type="text" name="elt_time" id="elt_time" placeholder="结束日期" class="datepicker" value="{$param.elt_time|default='0'|format_show_time=###,'only_date'}">
        </div>
        <div class="form-group">
          <label>关键词：</label>
          <div class="input-group">
            <span class="input-group-addon">
              <i class="ace-icon fa fa-check"></i>
            </span>
            <input type="text" name="keyword" id="keyword" class="form-control" value="{$param.keyword|default=''}" placeholder="请输入关键词" />
            <span class="input-group-btn">
              <button type="submit" class="btn btn-purple btn-sm">
                <span class="ace-icon fa fa-search icon-on-right bigger-110"></span>
                搜索
              </button>
            </span>
            </a>
          </div>
        </div>
        <div class="form-group">
          <a href="{:url('index')}" class="btn btn-sm  btn-purple ml-10">
            <span class="ace-icon fa fa-globe icon-on-right bigger-110"></span>
            显示全部
          </a>
        </div>
      </form>
    </div>
  </div>

  <div class="row">
    <div class="col-xs-12">
      <form method="post" action="{:url('resort')}" >
        <table class="table table-striped table-bordered table-hover" id="dynamic-table">
          <thead>
            <tr>
              <th class="field-style">排序编号</th>
              <th>标题</th>
              <th>分类名</th>
              <th class="center">状态</th>
              <th class="center">发布时间</th>
              <th class="center">更新时间</th>
              <th class="center">更新用户</th>
              <th class="center">操作</th>
            </tr>
          </thead>
          <tbody>
            <?php $list = $res->all(); ?>
            {volist name="$list" id="vo"}
              <tr>
                <td class="field-style center">
                  <input type="text" maxlength="4" name="items[{$vo.id}]" value="{$vo.sort}" class="field-style">
                </td>
                <td>
                  <a href="{:url('/index/notice/read', ['id' => $vo['id'], 'mode' => 'preview'])}" target="_blank">
                    {$vo.title}
                  </a>
                </td>
                <td>
                  {$vo.second_category_title}
                </td>
                <td class="center">
                  {$vo.status|get_field_text='status',###}
                </td>
                <td class="center">
                  {$vo.create_time}
                </td>
                <td class="center">
                  {$vo.update_time}
                </td>
                <td>
                  {$vo.member_name}
                </td>
                <td class="center">
                  <?php if($vo['status']): ?>
                    <a class="blue btn-copy" href="javascript:void(0);" data-clipboard-action="copy" data-clipboard-text="{:url('/index/notice/read', ['id' => $vo['id']], true, true)}">
                      <i class="ace-icon fa fa-copy bigger-130"></i>复制访问链接
                    </a>
                  <?php endif; ?>
                  <?php if($auth->check('update')): ?>
                    <a class="green" href="{:url('update', ['id' => $vo['id']])}">
                      <i class="ace-icon fa fa-pencil bigger-130"></i>编辑
                    </a>
                  <?php endif; ?>
                  <?php if($auth->check('delete')): ?>
                    <a class="red" href='javascript:void(0)' onclick="alert_del('{:url("delete", ['id' => $vo['id']])}', '确认要删除吗？');" class="tooltip-error" data-rel="tooltip" title="删除">
                      <i class="ace-icon fa fa-trash-o bigger-130"></i>删除
                    </a>
                  <?php endif; ?>
                </td>
              </tr>
            {/volist}
          </tbody>
        </table>
        <div class="row">
          <div class="col-xs-12">
            <?php if($auth->check('resort')): ?>
              <button class="btn btn-xs btn-info btn-resort" type="submit">
                更新排序
              </button>
            <?php endif; ?>
            <?php echo($res->render()); ?>
          </div>
        </div>
      </form>
    </div>
  </div>
{/block}
{block name="page_js"}
  <script src="{$site_root}/static/ace1.4/assets/js/bootstrap-datepicker.min.js"></script>
  <script src="{$site_root}/static/plugins/clipboard-2.0.0/clipboard.min.js"></script>
  <script type="text/javascript">
    $(document).ready(function(){
      $('.datepicker').datepicker({
        minView: "month", //选择日期后，不会再跳转去选择时分秒
        format: "yyyy-mm-dd", //选择日期后，文本框显示的日期格式
        language: 'zh-CN', //汉化
        autoclose:true //选择日期后自动关闭
      });

      var clipboard = new ClipboardJS('.btn-copy');
      clipboard.on('success', function(e) {
        alert('复制成功!');
      });
    });
  </script>
{/block}